package org.example.provider;

import org.example.framework.protocol.http.HttpServer;
import org.example.framework.register.LocalRegister;
import org.example.framework.register.RemoteMapRegister;
import org.example.provider.api.HelloService;
import org.example.provider.impl.HelloServiceImpl;
import org.example.provider.impl.HelloServiceImpl2;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Provider {

    private static final String HOSTNAME = "localhost";
    private static final Integer PORT = 8080;




    public static void main(String[] args) {

        try {
            LocalRegister.register(HelloService.class.getName(), HelloServiceImpl.class);
            LocalRegister.register(HelloService.class.getName(), "2", HelloServiceImpl2.class);

            URL url = new URL("http", HOSTNAME, PORT, "/");
            Set<String> tags = new HashSet<>();
            tags.add("A");
            RemoteMapRegister.register(HelloService.class.getName(), url,tags);

            HttpServer httpServer = new HttpServer();
            httpServer.start(HOSTNAME, PORT);
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
}
